package com.lvgang.springbootrabbitmq.helloworld;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.UUID;

/**
 * @author lvgang
 */
@Component
public class HelloWorldSender {

	private static Logger logger = LoggerFactory.getLogger(HelloWorldSender.class);

	@Autowired
	private RabbitTemplate rabbitTemplate;

	public void send() {
		CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
		String content = "HelloWorld= " + new Date() + ", content= " + UUID.randomUUID().toString();
		this.rabbitTemplate.convertAndSend(RabbitHelloWorldConstant.QUEUQ,(Object) content,correlationData);
		logger.info("Send ok,"+new Date()+","+content);
	}
}